package com.sgcc.fj.pmos.e_fj_mall.activity;

import android.os.Bundle;
import android.view.View;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.flyco.tablayout.SlidingTabLayout;
import com.sgcc.fj.pmos.arouter.mall.MallArouterPath;
import com.sgcc.fj.pmos.common.adapter.HomeTabPagerAdapter;
import com.sgcc.fj.pmos.common.base.BasePresenter;
import com.sgcc.fj.pmos.common.base.MvpBaseActivity;
import com.sgcc.ln.pmos.common.widget.TitleBar;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.fj.pmos.e_fj_mall.fragment.CurveFragment;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
@Route(path = MallArouterPath.MALL_AUTOCURVESETTING)
public class AutoCurveSettingActivity extends MvpBaseActivity {

    private TitleBar mTitleBar;
    private SlidingTabLayout mStlContent;
    private ViewPager mViewpager;
    private List<Fragment> fragments = new ArrayList<>();
    private HomeTabPagerAdapter homeTabPagerAdapter;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_autocurvesetting;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected void initViews() {
        super.initViews();
        mTitleBar = (TitleBar) findViewById(R.id.title_bar);
        mStlContent = (SlidingTabLayout) findViewById(R.id.stl_content);
        mViewpager = (ViewPager) findViewById(R.id.viewpager);

        mTitleBar.setTitle("设置电量比例");
        mTitleBar.setRightIcon(R.mipmap.go_main, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                goMainActivity();
            }
        });

        String[] titleList = getResources().getStringArray(R.array.mall_auto_curve_setting);

        CurveFragment leftCurveFragment = new CurveFragment();
        Bundle left_bundle = new Bundle();
        left_bundle.putString("tab", "left");
        leftCurveFragment.setArguments(left_bundle);
        CurveFragment rightCurveFragment = new CurveFragment();
        Bundle right_bundle = new Bundle();
        right_bundle.putString("tab", "right");
        rightCurveFragment.setArguments(right_bundle);

        fragments.add(leftCurveFragment);
        fragments.add(rightCurveFragment);
        homeTabPagerAdapter = new HomeTabPagerAdapter(getSupportFragmentManager(), fragments);
        homeTabPagerAdapter.setmBottomTabNames(titleList);
        mViewpager.setOffscreenPageLimit(2);
        mViewpager.setAdapter(homeTabPagerAdapter);
        mStlContent.setViewPager(mViewpager);
        mViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }
}
